#include "BlockQueue.hpp"

void* Consumer(void *args)
{
    BlockQueue<int> *bq = static_cast<BlockQueue<int> *>(args);
    while (true)
    {
        sleep(1);
        int data = 0;
        bq->bqPop(&data);
        std::cout << "consumer :" << data<< std::endl;
    }
    return nullptr;
}

void* Productor(void *args)
{
    BlockQueue<int> *bq = static_cast<BlockQueue<int> *>(args);
    srand(time(nullptr));
    while (true)
    {
        int data = rand();
        bq->bqEqueue(data);
        std::cout << "Productor success" << std::endl;
        sleep(1);
    }
}
int main()
{
    BlockQueue<int> bq(10);
    bq.bqInit();

    pthread_t c, p;

    pthread_create(&p, nullptr, Productor, (void *)&bq);
    pthread_create(&c, nullptr, Consumer, (void *)&bq);

    sleep(100);
    return 0;
}
